package dome1.network;

import java.io.IOException;
import java.net.SocketException;
import java.util.HashMap;

public class UdpDictServer extends UdpEchoServer{
    private HashMap<String, String> dict = null;

    public UdpDictServer(int port) throws SocketException {
        super(port);

        dict = new HashMap<>();
        dict.put("hello", "你好");
        dict.put("cat", "小猫");
        dict.put("dog", "小狗");
        dict.put("fish", "鱼");
        dict.put("pig", "小猪");

    }

    @Override
    public String process(String request) {
        return dict.getOrDefault(request,"该词汇没有查到");
    }

    public static void main(String[] args) throws IOException {
        UdpDictServer server = new UdpDictServer(9090);
        server.start();
    }
}
